﻿@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}


<div id="roleListTable" class="main-content">
    <h3 class="page-title">角色管理(菜单管理)Role management(Menu management)</h3>

    <div class="panel">
        <div class="panel-body">
            <button class="btn btn-primary" v-on:click="AddRole">
                <i class="fa fa-user-plus"></i> 新增角色New role
            </button>
            <br />
            <br />
            <table class="table table-striped" v-if="isNotEmptyObject(roleList)">
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>角色名称Role name</th>
                        <th>菜单名称Menu name</th>
                        <th>菜单路径Menu path</th>
                        <th>菜单图标Menu icon</th>
                        <th>菜单优先级Menu priority</th>
                        <th>是否禁用whether Disable</th>
                        <th>父角色IDParent roleID</th>
                        <th>操作operation</th>
                    </tr>
                </thead>
                <tbody v-for="(role, index) in roleList">
                    <tr :id='"inputArea" + role.BaseInfo.ID' class="info">
                        <td>
                            <div class="form-group">
                                <label class="form-control">{{role.BaseInfo.ID}}</label>
                                <input type="hidden" class="form-control" v-model="role.BaseInfo.ID" />
                            </div>
                        </td>
                        <td>
                            <div :id='"inputName" + role.BaseInfo.ID' class="form-group">
                                <input type="text" class="form-control" v-model="role.BaseInfo.Name" />
                            </div>
                        </td>
                        <td>
                            <div :id='"inputPageName" + role.BaseInfo.ID' class="form-group">
                                <input type="text" class="form-control" v-model="role.BaseInfo.PageName" />
                            </div>
                        </td>
                        <td>
                            <div :id='"inputPagePath" + role.BaseInfo.ID' class="form-group">
                                <input type="text" class="form-control" v-model="role.BaseInfo.PagePath" />
                            </div>
                        </td>
                        <td>
                            <div :id='"inputIcon" + role.BaseInfo.ID' class="form-group">
                                <input type="text" class="form-control" v-model="role.BaseInfo.Icon" />
                            </div>
                        </td>
                        <td>
                            <div :id='"inputPriority" + role.BaseInfo.ID' class="form-group">
                                <input type="text" class="form-control" v-model="role.BaseInfo.Priority" />
                            </div>
                        </td>
                        <td>
                            <div class="form-group">
                                <select class="form-control" v-model="role.BaseInfo.IsDisable">
                                    <option v-for="(value, key, idx) in isDisableDictionary" v-bind:value="value">{{key}}</option>
                                </select>
                            </div>
                        </td>
                        <td>
                            <div class="form-group">
                                <label class="form-control">{{role.BaseInfo.ParentID}}</label>
                                <input type="hidden" class="form-control" v-model="role.BaseInfo.ParentID" />
                            </div>
                        </td>
                        <td>
                            <button :id='"btnSave" + role.BaseInfo.ID' class="btn btn-success btn-sm" v-on:click="SaveRole(role.BaseInfo)" v-if="role.BaseInfo.ID == 0">
                                <i class="fa fa-save"></i> 保存preservation
                            </button>
                            <button :id='"btnCancelSave" + role.BaseInfo.ID' class="btn btn-warning btn-sm" v-on:click="CancelSaveRole(role.BaseInfo)" v-if="role.BaseInfo.ID == 0">
                                <i class="fa fa-close"></i> 取消cancel
                            </button>
                            <button :id='"btnEdit" + role.BaseInfo.ID' class="btn btn-info btn-sm" v-on:click="EditRole(role.BaseInfo)" v-if="role.BaseInfo.ID > 0">
                                <i class="fa fa-edit"></i> 编辑edit
                            </button>
                            <button :id='"btnUpdate" + role.BaseInfo.ID' class="btn btn-primary btn-sm" style="display: none;" v-on:click="UpdateRole(role.BaseInfo)">
                                <i class="fa fa-refresh"></i> 更新renew
                            </button>
                            <button :id='"btnCancelUpdate" + role.BaseInfo.ID' class="btn btn-warning btn-sm" style="display: none;" v-on:click="CancelUpdateRole(role.BaseInfo)">
                                <i class="fa fa-close"></i> 取消cancel
                            </button>
                            <button :id='"btnDelete" + role.BaseInfo.ID' class="btn btn-danger btn-sm" style="display: none;" v-on:click="DeleteRole(role.BaseInfo)">
                                <i class="fa fa-trash-o"></i> 删除delete
                            </button>
                            <button :id='"btnAddSubRole" + role.BaseInfo.ID' class="btn btn-success btn-sm" v-on:click="AddSubRole(role)" v-if="role.BaseInfo.ID > 0 && !hasEditRole">
                                <i class="fa fa-user-plus"></i> 新增子角色New sub role
                            </button>
                        </td>
                    </tr>
                    <tr :id='"inputArea" + subRole.ID' v-for="(subRole, subIndex) in role.SubRoles">
                        <td>
                            <div class="form-group">
                                <input type="hidden" class="form-control" v-model="subRole.ID" />
                            </div>
                        </td>
                        <td>
                            <div :id='"inputName" + subRole.ID' class="form-group">
                                <input type="text" class="form-control" v-model="subRole.Name" />
                            </div>
                        </td>
                        <td>
                            <div :id='"inputPageName" + subRole.ID' class="form-group">
                                <input type="text" class="form-control" v-model="subRole.PageName" />
                            </div>
                        </td>
                        <td>
                            <div :id='"inputPagePath" + subRole.ID' class="form-group">
                                <input type="text" class="form-control" v-model="subRole.PagePath" />
                            </div>
                        </td>
                        <td>
                            <div :id='"inputIcon" + subRole.ID' class="form-">
                                <input type="text" class="form-control" v-model="subRole.Icon" />
                            </div>
                        </td>
                        <td>
                            <div :id='"inputPriority" + subRole.ID' class="form-group">
                                <input type="text" class="form-control" v-model="subRole.Priority" />
                            </div>
                        </td>
                        <td>
                            <div class="form-group">
                                <select class="form-control" v-model="subRole.IsDisable">
                                    <option v-for="(value, key, idx) in isDisableDictionary" v-bind:value="value">{{key}}</option>
                                </select>
                            </div>
                        </td>
                        <td>
                            <div class="form-group">
                                <label class="form-control">{{subRole.ParentID}}</label>
                                <input type="hidden" class="form-control" v-model="subRole.ParentID" />
                            </div>
                        </td>
                        <td>
                            <button :id='"btnSave" + subRole.ID' class="btn btn-success btn-sm" v-on:click="SaveRole(subRole)" v-if="subRole.ID == 0">
                                <i class="fa fa-save"></i> 保存preservation
                            </button>
                            <button :id='"btnCancelSave" + subRole.ID' class="btn btn-warning btn-sm" v-on:click="CancelSaveRole(subRole)" v-if="subRole.ID == 0">
                                <i class="fa fa-close"></i> 取消cancel
                            </button>
                            <button :id='"btnEdit" + subRole.ID' class="btn btn-info btn-sm" v-on:click="EditRole(subRole)" v-if="subRole.ID > 0">
                                <i class="fa fa-edit"></i> 编辑edit
                            </button>
                            <button :id='"btnUpdate" + subRole.ID' class="btn btn-primary btn-sm" style="display: none;" v-on:click="UpdateRole(subRole)">
                                <i class="fa fa-refresh"></i> 更新renew
                            </button>
                            <button :id='"btnCancelUpdate" + subRole.ID' class="btn btn-warning btn-sm" style="display: none;" v-on:click="CancelUpdateRole(subRole)">
                                <i class="fa fa-close"></i> 取消cancel
                            </button>
                            <button :id='"btnDelete" + subRole.ID' class="btn btn-danger btn-sm" style="display: none;" v-on:click="DeleteRole(subRole)">
                                <i class="fa fa-trash-o"></i> 删除delete
                            </button>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
    <!-- END TABLE -->
    <div class="alert alert-warning alert-dismissible" role="alert">
        <i class="fa fa-warning"></i>
        <p>角色的作用，会影响用户左边菜单栏显示或隐藏。The role will affect the display or hiding of the menu bar on the left of the user</p>
        <p>如需修改用户角色，请在【用户管理】下【编辑】可以进行角色更新了，同时会在用户下一次登录时生效。To modify the user role, please click Edit under user management to update the role, which will take effect when the user logs in next time</p>
    </div>
</div>


@section scripts{
    <script type="text/javascript" src="~/Scripts/pageJs/Account/Role.js?v=@DateTime.Now.ToFileTimeUtc()"></script>
}
